﻿using BLL.Access;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;
using Entity;
using BLL;
using DevExpress.Web;

namespace Web.Controls
{
    public partial class UCLHFenHuShuiBiaoList : System.Web.UI.UserControl, IUCLHOperate
    {
        #region 属性

        /// <summary>
        /// 记录查询结果集
        /// </summary>
        private DataTable dtSource
        {
            get
            {
                return ViewState["dtSource"] as DataTable;
            }
            set
            {
                ViewState["dtSource"] = value;
            }
        }

        /// <summary>
        /// 来函类型
        /// </summary>
        public eLaiHanLX LaiHanLX { get; set; }

        /// <summary>
        /// 来函流程步骤
        /// </summary>
        public eLaiHanLCBH LaiHanLC {
            get
            {
                return ViewState["LaiHanLC"]==null?eLaiHanLCBH.未登记:(eLaiHanLCBH)Enum.Parse(typeof(eLaiHanLCBH), Convert.ToString(ViewState["LaiHanLC"])); 
            }
            set
            {
                ViewState["LaiHanLC"] = value.ToString();
            }        
        }

        /// <summary>
        /// 设置复选框列显隐
        /// </summary>
        public bool ShowCheck;

        /// <summary>
        /// 记录来函编号
        /// </summary>
        public string LaiHanBH 
        {
            get 
            {
                return Convert.ToString(ViewState["LaiHanBH"]);
            }
            set
            {
                ViewState["LaiHanBH"] = value;
            }
        }

        /// <summary>
        /// 设置列表高度
        /// </summary>
        public int ListHeight
        {
            set
            {
                this.gvList.Settings.VerticalScrollableHeight = value;
            }
        }

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();
            }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 配置控件
        /// </summary>
        public void InitControl()
        {

        }

        /// <summary>
       ///重新绑定
        /// </summary>
        public void BindData()
        {
            this.gvList.DataSource = this.dtSource;
            this.gvList.DataBind();
        }

        /// <summary>
        /// 清空数据
        /// </summary>
        public void ClearInfo()
        {
            this.dtSource = null;
            this.gvList.DataSource = null;
            this.gvList.DataBind();
        }

        /// <summary>
        /// 验证
        /// </summary>
        /// <returns></returns>
        public ValidateRS Validate()
        {
            ValidateRS rs = new ValidateRS();
            rs.IsSuccess = true;
            return rs;
        }

        /// <summary>
        /// 根据来函加载信息
        /// </summary>
        /// <param name="laihanxx"></param>
        public void LoadInfo(YS_LH_LAIHANXX laihanxx)
        {
            this.dtSource = new YS_LH_YONGHUTZBLL().SelectYS_LH_YONGHUTZsDynamic(String.Format("I_JLZT=0 and I_LEIXING=0 and S_LAIHANBH = '{0}'", laihanxx.S_LAIHANBH), null);
            this.BindData();
        }        

        #endregion        
    }
}